<?php

/**
 * Lot form base class.
 *
 * @method Lot getObject() Returns the current form's model object
 *
 * @package    appcemhti
 * @subpackage form
 * @author     Steve Cancès
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseLotForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_lot'          => new sfWidgetFormInputHidden(),
      'id_fournisseur'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'add_empty' => true)),
      'id_matiere'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Matiere'), 'add_empty' => false)),
      'id_user'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
      'nom'             => new sfWidgetFormInputText(),
      'polytype'        => new sfWidgetFormInputText(),
      'date_recep'      => new sfWidgetFormDateTime(),
      'created_at'      => new sfWidgetFormDateTime(),
      'updated_at'      => new sfWidgetFormDateTime(),
      'fichier_analyse' => new sfWidgetFormInputText(),
      'confidentiel'    => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id_lot'          => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_lot')), 'empty_value' => $this->getObject()->get('id_lot'), 'required' => false)),
      'id_fournisseur'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Fournisseur'), 'required' => false)),
      'id_matiere'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Matiere'))),
      'id_user'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
      'nom'             => new sfValidatorString(array('max_length' => 32)),
      'polytype'        => new sfValidatorString(array('max_length' => 32, 'required' => false)),
      'date_recep'      => new sfValidatorDateTime(array('required' => false)),
      'created_at'      => new sfValidatorDateTime(array('required' => false)),
      'updated_at'      => new sfValidatorDateTime(array('required' => false)),
      'fichier_analyse' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'confidentiel'    => new sfValidatorInteger(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('lot[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Lot';
  }

}
